package rx.genarator.comprehension;

import java.util.HashSet;
import java.util.Set;

public class Key {
	
	protected String id;
	protected String name;
	protected String code;
	private TableOrView tableOrView;
	
	protected Set<Column> columns ;

	public String getCode() {
		return code;
	}

	public Set<Column> getColumns() {
		return new HashSet<Column>(columns);
	}

	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public Key(TableOrView tableOrView,String id, String name, String code, Set<Column> columns) {
		super();
		if(id == null || name == null || code == null || columns == null || columns.size()==0){
			throw new IllegalArgumentException("id:" + id + ",name:" + name +",code:" + code + ",columns:" + columns);
		}
		this.tableOrView = tableOrView;
		this.id = id;
		this.name = name;
		this.code = code;
		this.columns = columns;
		this.tableOrView.addKey(this);
		ObjectsMap.put(id, this);
	}

	public TableOrView getTableOrView() {
		return tableOrView;
	}
	
}
